package demo05;

/**
 * @author JYH
 * @version 1.0
 * @date 2022/11/1 9:46
 */
public class TestYieldDemo {
    public static void main(String[] args) {
        YieldDemo yieldDemo = new YieldDemo();
        yieldDemo.start();

        for (int i = 0; i < 10; i++) {

            System.out.println(Thread.currentThread().getName()+"==="+i);
        }

    }
}
class YieldDemo extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"==="+i);
            Thread.yield();
        }
    }
}
